home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8403 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: ix.netcom.com!netnews
  2. From: sstrader@ix.netcom.com (Scott Strader )
  3. Newsgroups: comp.lang.c++
  4. Subject: Getting Pointer to Dialog
  5. Date: 17 Feb 1996 20:56:22 GMT
  6. Organization: Netcom
  7. Message-ID: <4g5fdm$d5b@cloner4.netcom.com>
  8. NNTP-Posting-Host: atl-ga8-18.ix.netcom.com
  9. X-NETCOM-Date: Sat Feb 17 12:56:22 PM PST 1996
  10.  
  11. I'm using MSVC++ 4.0 with MFC and am having a problem with referencing a 
  12. control on a dialog.  I've got a workaround for this problem, but am 
  13. curious if anyone knows why it's happening.
  14.  
  15. I'm in a function outside of the dialog class, so I need to get a pointer 
  16. to that class.  I had used the .m_pMainWnd member of my application 
  17. class, then cast it as a pointer to my specific dialog class:
  18.  
  19. CPatchwmDlg *    theDlg = (CPatchwmDlg *)theApp.m_pMainWnd;
  20.  
  21. Made sense to me.  Unfortunately, I got unhandled exception errors 
  22. whenever I tried to use theDlg as a pointer to my class.  When I looked 
  23. at the address of theDlg and the address of .m_pMainWnd, I found that 
  24. they were different and that the hWnds were different.  I eventually read 
  25. that the proper way is to use the .GetDlgItem() member function to get 
  26. the hWnd of the specific control on the dialog.
  27.  
  28. I'm still curious as to why the original method did not work.  If anybody 
  29. has any info, thanks.
  30.  
  31. Scott S.
  32.